const state={
	studentEntryDialog: false,
	studentEntryList:[]
};
const getters={
	
	isShow(state) {  //方法名随意,主要是来承载变化的studentEntryDialog的值
       return state.studentEntryDialog
   },
   getStudentEntryList(state){
   	return state.studentEntryList
   }
};

const mutations = {
	show(state) {   //自定义改变state初始值的方法，这里面的参数除了state之外还可以再传额外的参数(变量或对象);
        state.studentEntryDialog = true;
    },
    hide(state) {  //同上
        state.studentEntryDialog = false;
    },
    setStudentEntryList(state,data){
    	state.studentEntryList=[];
    	state.studentEntryList=data;
    }
};

const actions = {
	hidestudentEntryPanel(context) {  //自定义触发mutations里函数的方法，context与store 实例具有相同方法和属性
        
        context.commit('hide');
    },
    showstudentEntryPanel(context) {  //同上注释
    	
        context.commit('show');
    },
    getStudentEntryList(context,classid){
    	let paras={classId:classid};
    	api.getStudentEntryList(paras).then(function(data){
    		 console.log(data)
    		 if(data.result=="操作成功"){
    		 	 context.commit('show');
    		 	 for(let i = 0;i<data.studentList.length;i++){//处理年龄
    		 	 	
    		 	 	data.studentList[i].age = tool.minusDate(data.studentList[i].birthday)||"";
    		 	 	data.studentList[i].checked = false;
    		 	 	data.studentList[i].index = (i+1);
    		 	 }
    		 	 console.log(data.studentList)
    		     context.commit('setStudentEntryList',data.studentList);
    		 }
    		
    	})
    }
};

module.exports = {
	  namespaced:true,//用于在全局引用此文件里的方法时标识这一个的文件名
	  state,
	  getters,
	  actions,
	  mutations
}